package com.wgzx.modbus.codec;

import com.wgzx.modbus.entity.ModbusRspFrame;
import com.wgzx.modbus.serialize.ModbusFrameSerialization;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

import java.util.List;

public class ModbusDecoder extends ByteToMessageDecoder {

    @Override
    protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> list) {
        ModbusRspFrame frame = ModbusFrameSerialization.INSTANCE.deserialize(byteBuf);
        list.add(frame);
    }
}
